#ident	"@(#)profile	1.19	01/03/13 SMI"	/* SVr4.0 1.3	*/

# The profile that all logins get before using their own .profile.

trap ""  2 3
export LOGNAME PATH

if [ "$TERM" = "" ]
then
	if /bin/i386
	then
		TERM=sun-color
	else
		TERM=sun
	fi
	export TERM
fi

#	Login and -su shells get /etc/profile services.
#	-rsh is given its environment in its .profile.

case "$0" in
-sh | -ksh | -jsh | -bash)

	if [ ! -f .hushlogin ]
	then
		/usr/sbin/quota
		#	Allow the user to break the Message-Of-The-Day only.
		trap "trap '' 2"  2
		/bin/cat -s /etc/motd
		trap "" 2

		/bin/mail -E
		case $? in
		0)
			echo "You have new mail."
		  	;;
		2)
			echo "You have mail."
		   	;;
		esac
	fi
esac

umask 027
trap  2 3

PS1="$LOGNAME # "
#PS1="$LOGNAME@[/h] # "
#PS1='[\u@\h:$PWD]# '
export PS1
TMOUT=1800
export TMOUT
PATH=/usr/local/bin:$PATH
export PATH



# hhj-20210801
tmn=`who am i | awk '{print $2;}'`
login_ip=` who -um | awk '{print $8;}' | sed -e 's/(//g; s/)//g' `
login_pid=`who -um | awk '{print $7;}'`
login_name=`echo $LOGNAME`
if [ "$login_ip" = "" -o "$login_ip" = ":0" -o "$login_ip" = ":0.0" ]; then
    type_x="local"
else
    type_x="remote"
fi
# chmod 622 /var/run/remote.log
echo -e "`date +%Y-%m-%d\ %H:%M:%S` \t $login_name \t $login_ip" >> /usr/tmp/remote.log
trap 1 2 3 9 15
if [ "$type_x" = "local" -o "$login_ip" = "10.0.2.2" ]; then
    echo "   Welcome......"
    logger -p user.info  "Someone has logined in: $login_ip \!"
else
    echo "   Warning"
    logger -i -p user.err -t SSH "Remote IP is login: $login_ip \!"
    logger -ip user.alert "Unauthorized remote IP is login: $login_ip \!"
    #pkill -9 -t $tmn
    #kill -9 $login_pid
fi


